/* 
* @Author: anchen
* @Date:   2015-12-31 14:14:54
* @Last Modified by:   anchen
* @Last Modified time: 2015-12-31 14:14:56
*/

'use strict';
$(function () { 
      
      $("body").click(function(){
         $(".popover").hide();
      })
      $(".user,.list-unstyled").hover(function(e){
         e.stopPropagation();
         $(".list-unstyled ").show();
      },function(){
        $(".list-unstyled ").hide();
      })
    //banner_one
    var liW=$(".banner_one ul li").width()+20;
    var liL=$(".banner_one ul li").length;
    var widthBannerOne=Number(liW*liL);
    var heightBannerOne=$(".banner_one ul li").height();
    $(".banner_one").css({"height":heightBannerOne+"px"});
    $(".banner_one  .banner_one_box").css({"width":widthBannerOne+"px","height":heightBannerOne+"px"});
    var i=3;
    var page=1;
    $(".banner_one .next").click(function(){
        var $parent=$(this).parents(".banner_one");
        var $v_content=$parent.find(".banner_one_box"); 
        var len=$v_content.find("li").length;
        var page_count=Math.ceil(len - i);
        
        if(page==page_count){
            $v_content.animate({left:'0px'}, 'slow');
            page=1;
        }else{
            $v_content.animate({left:'-='+liW},'slow');
            page++;
        }
    })
   $(".banner_one .pre").click(function(){
        var $parent=$(this).parents(".banner_one");
        var $v_content=$parent.find(".banner_one_box"); 
        var len=$v_content.find("li").length;
        var page_all=Math.ceil(len - i);
        if(page==1){
            $v_content.animate({
                left:"-="+liW*(page_all-1)},"slow");
            page=page_all;
        }
        else{
            $v_content.animate({left:"+="+liW}, "slow");
             page--;
        }
   })
   //banner_two
    var liWIn=$(".banner_two  ul li").width()+2;
    var dlW=$(".banner_two .detail dl").width()+20;
    var liLIn=$(".banner_two  ul li").length;
    var widthBannerTwo=Number(liWIn*liLIn);
    var detailWidth=Number(dlW*liLIn);
    var heightBannerTwoD=$(".banner_two .detail").height();
    var heightBannerTwoN=$(".banner_two .name").height();
    var heightBannerTwo=Number(heightBannerTwoD+heightBannerTwoN);
    $(".banner_two .name").css({"width":widthBannerTwo+"px"});
     $(".banner_two ul li").click(function(){
     	  var liIndex=$(this).index();
     	  $(".banner_two .detail").css({left:dlW*(-liIndex)});
     })
    var j=4;
    var page_=1;
    $(".banner_two .next").on("click",function(){
        var $parent=$(this).parents(".banner_two");
        var $v_contentDetail=$parent.find(".detail"); 
        var $v_contentName=$parent.find(".name");
        var len=$v_contentName.find("li").length;
        var page_count=Math.ceil(len - j);
        if(page_==page_count){
            $v_contentDetail.animate({left:'0px'}, 'slow');
            $v_contentName.animate({left:'0px'}, 'slow');
            page_=1;
        }else{
            $v_contentDetail.animate({left:'-='+dlW},'slow');
            $v_contentName.animate({left:'-='+liWIn},'slow');
            page_++;
        }
    })
    $(".banner_two .pre").on("click",function(){
        var $parent=$(this).parents(".banner_two");
        var $v_contentDetail=$parent.find(".detail"); 
        var $v_contentName=$parent.find(".name");
        var len=$v_contentName.find("li").length;
        var page_all=Math.ceil(len - j);
//      $v_contentDetail.css({left:'0px'});
//      $v_contentName.css({left:'0px'});
        if(page_==1){
        	  $v_contentDetail.animate({left:"-="+dlW*(page_all-1)}, 'slow');
            $v_contentName.animate({left:"-="+liWIn*(page_all-1)}, 'slow');
            page_=page_all;
            $v_contentDetail.css({left:'0px'});
            $v_contentName.css({left:'0px'});
        }
        else{
//      	$v_contentDetail.css({left:'0px'});
//        $v_contentName.css({left:'0px'});
        	  $v_contentDetail.animate({left:"+="+dlW}, 'slow');
            $v_contentName.animate({left:"+="+liWIn}, 'slow');
            page_--;
        }
   })
     //footer
      var boxH=$(".box").height();
      console.log(boxH);
      $(".footer").css({"top":boxH+160+"px"});
}); 
